package org.zk.dubbo_provider.service.impl;



import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.zk.dubbo_provider.dao.TypeMapper;
import org.zk.entity.AdminBill;
import org.zk.entity.Type;
import org.zk.service.TypeService;
import com.alibaba.dubbo.config.annotation.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * 课程类型表 服务实现类
 * </p>
 *
 * @author Alicelonely
 * @since 2019-12-11
 */
@Service(timeout = 10000)
public class TypeServiceImpl  implements TypeService {

    @Resource
    private TypeMapper typeMapper;

    //查询所有的一级分类
    @Override
    public List<Type> getAllType() {
        return typeMapper.getAllType();
    }

    public PageInfo getAllTypesPage(Map map){
        PageInfo<Type> pageInfo;
        int pageSize=Integer.parseInt(String.valueOf(map.get("pageSize")));
        int pageNum=Integer.parseInt(String.valueOf(map.get("pageNum")));
        PageHelper.startPage(pageNum,pageSize);
        try {
            List<Type> list=typeMapper.getAllTypePages(map);
            pageInfo = new PageInfo<>(list,pageSize);
        }finally {
            PageHelper.clearPage(); //清理 ThreadLocal 存储的分页参数,保证线程安全
        }
        return pageInfo;
    }

    @Override
    public int addType(String typeName) {
        return typeMapper.addType(typeName);
    }

    @Override
    public String getTypeById(int id) {
        return typeMapper.getTypeById(id);
    }

    @Override
    public int updateType(Map map) {
        return typeMapper.updateType(map);
    }

    @Override
    public int delTypeSubjectCourseByTid(int id) {
        return typeMapper.delTypeSubjectCourseByTid(id);
    }

    //查询一级分类qds专享版
    @Override
    public List<Type> getShowType() {
        return typeMapper.getShowType();
    }


    public TypeMapper getTypeMapper() {
        return typeMapper;
    }

    public void setTypeMapper(TypeMapper typeMapper) {
        this.typeMapper = typeMapper;
    }
}
